Fix face detection failures for non-photorealistic images#1037
Open
cab66420 wants to merge 1 commit intoOpenTalker:mainfrom
Open
Fix face detection failures for non-photorealistic images#1037cab66420 wants to merge 1 commit intoOpenTalker:mainfrom
cab66420 wants to merge 1 commit intoOpenTalker:mainfrom
Conversation
When using --preprocess full with anime/illustrated images, face detection fails at two points and crashes with unhelpful errors: 1. croper.py: `raise 'string'` was invalid Python 3 syntax and lm=None check didn't handle the full-mode case. Now returns the full image as crop/quad ([0,0,W,H]) so processing continues without a detected face. 2. extract_kp_videos_safe.py: `bboxes[0]` raises IndexError when detect_faces() returns an empty array. Added IndexError to the existing TypeError handler so it falls back to -1 keypoints, which preprocess.py already handles gracefully. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
****: Fixed invalid syntax (Python 3 requires ). Added a graceful fallback when landmark detection returns or empty in preprocess mode - returns the full image dimensions as / () so the pipeline continues without a detected face.
****: raises when returns an empty array (no face found). Added to the existing handler so it falls back to keypoints, which already handles gracefully via the check.
Motivation
When using with anime, illustrated, or stylized portrait images, real face detectors (RetinaFace / dlib) frequently return no detections. Before this fix, the pipeline crashed with either a (from the invalid statement) or an unhandled . These changes allow SadTalker to process non-photorealistic source images without errors.
Test plan